package com.walleipt.demo.aop.aspectj;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;


@Aspect
public class AspectJLoger {

	// execution (public String com.walleipt.demo.aop.aspectj.Printer.printName(String) )
	
	 
	@SuppressWarnings("unused")
	@Pointcut("execution (public String com.walleipt.demo.aop.aspectj.*.*(..) )")
	private void log(){} 
	
	@Before("log()")
	public void before(JoinPoint joinPoint) {
		System.err.println( "AspectJLoger...before...........\n\t"+joinPoint.getSignature()+"【"+joinPoint.getArgs()+"】");
	}
	
	@After(value="log()")
	public void after(JoinPoint joinPoint) {
		System.err.println( "AspectJLoger...after...........\n\t"+joinPoint.getSignature()+"【"+joinPoint.getArgs()+"】" );
	}
	
	@AfterReturning(value="log()",returning="result")
	public void afterReturning(JoinPoint joinPoint,Object result) {
		System.err.println( "AspectJLoger...afterReturning...........\n\t"+joinPoint.getSignature()+"【"+joinPoint.getArgs()+"】"+result );
	}
	
	@AfterThrowing("log()")
	public void afterThrowing() {
		System.err.println( "AspectJLoger...afterThrowing..........." );
	}
	
	/*
	@Around("execution (public String com.walleipt.demo.aop.aspectj.Printer.printName(String) )")
	public void around() {
		System.err.println( "AspectJLoger...around..........." );
	}
	*/
	
}
